package cont;

import java.sql.*;

public class contr {
    private static Connection conn = null;

    public static Connection getConn() {

        try {
            Class.forName("com.mysql.cj.jdbc.Driver");
            System.out.println("加载驱动成功");
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("加载驱动失败");
        }

        String url = "jdbc:mysql://localhost:3306/library?&useSSL=false&serverTimezone=UTC";
        String user = "root";
        String password = "253261";

        try {
            conn = DriverManager.getConnection(url, user, password);
            System.out.println("连接数据库成功");
        } catch (Exception e) {
            // TODO: handle exception
            e.printStackTrace();
            System.out.println("数据库连接失败");
        }
        return conn;
    }



}
